package kr.co.exight.onApp;

import library.Library;

import org.json.JSONException;
import org.json.JSONObject;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class ActivityTimeDetail extends Activity {

	/** Called when the activity is first created. */
	public static JSONObject data;

	@Override
	public void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
		//arrCompanyInfo = ActivityTabOncard.getArrayData();
	    setContentView(R.layout.act_carddetail);
	    
	    RelativeLayout rlNaviBar = (RelativeLayout)findViewById(R.id.cardDetail_naviBar);
	    
	    rlNaviBar.setBackgroundResource(R.drawable.navi_ontime);

	    TextView tvCategory = (TextView)findViewById(R.id.cardDetail_tvCategory);
	    TextView tvName = (TextView)findViewById(R.id.cardDetail_tvName);
	    
	    TextView tvLocation = (TextView)findViewById(R.id.cardDetail_tvLocation);
	    TextView tvDiscount = (TextView)findViewById(R.id.cardDetail_tvDiscount);
	    TextView tvNote = (TextView)findViewById(R.id.cardDetail_tvNote);
	    
	    
	    Library.setFontNanumGothic(tvName);
	    Library.setFontNanumGothic(tvLocation);

	    Library.setFontNanumGothic(tvCategory);
	    Library.setFontNanumGothic(tvDiscount);
	    Library.setFontNanumGothic(tvNote);
	    
	    
	    Library.setTextViewBold(tvName);
	    Library.setTextViewBold(tvCategory);
	    
	    
/*	    TextView tvIntroduce = (TextView)findViewById(R.id.cardDetail_tvIntroduce);
	    TextView tvSale = (TextView)findViewById(R.id.cardDetail_tvSale);
	    TextView tvDescript = (TextView)findViewById(R.id.cardDetail_tvEtc);*/
	    
	    Button btnMap = (Button)findViewById(R.id.cardDetail_btnMap);
		Button btnSale = (Button)findViewById(R.id.cardDetail_btnSale);

	    btnMap.setOnClickListener(new OnClickListener() {
			
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent i = new Intent(ActivityTimeDetail.this, ActivityTabOncard.class);
				try {
					i.putExtra("long", data.getJSONObject("position").getDouble("longitude"));
					i.putExtra("lati", data.getJSONObject("position").getDouble("longitude"));
				} catch (JSONException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				startActivity(i);
			}
		});
	    btnSale.setOnClickListener(new OnClickListener() {

			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent i = new Intent(ActivityTimeDetail.this, ActivityCard.class);
				startActivity(i);
			}
		});

	    
	     try{
	    	tvCategory.setText("");
	    	
	    	tvName.setText(data.getString("name"));
	 	    
	    	
	    	tvLocation.setText(data.getString("address"));
			
	    	if(!data.isNull("discount"))
	    		tvDiscount.setText(data.getString("discount"));
	    	
	    	if(!data.isNull("note"))
	    		tvDiscount.setText(data.getString("note"));
	    	
	    	/*tvIntroduce.setText("준비 중입니다.");
			tvSale.setText("준비 중입니다.");
			tvDescript.setText("준비 중입니다.");*/
			
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	    
	}
	
	public static void setJSONData(JSONObject _data){
		data = _data;
	}
}
